<template>
  <view class="background-white">
    <view class="bor-btm">
      报警类型：<text>{{ detail.alarmDesc || '--' }}</text>
    </view>
    <view class="bor-btm">
      报警内容：<text>{{ detail.alarmContent || '--' }}</text>
    </view>
    <view class="bor-btm">
      报警事件：<text>{{ detail.alarmTime || '--' }}</text>
    </view>
    <view class="bor-btm">
      有效时间：<text>{{ detail.effectiveTime || '--' }}</text>
    </view>
    <view class="bor-btm"> 报警位置：<button class="info-btn" @click="goDetail">查看</button> </view>
    <view class="bor-btm">
      {{ alarmSourceText }}：<text>{{ detail.alarmSource || '--' }}</text>
    </view>
    <view class="bor-btm">
      推送人员：<text>{{ pushStaffNames || '--' }}</text>
    </view>
    <view v-if="!hiddenResult" class="bor-btm">
      处理记录：<text>{{ detail.handleResult || '--' }}</text>
    </view>
  </view>
</template>

<script>
import { getToken } from '@/utils/auth'
import { staticUrl } from '@/config.js'

export default {
  name: 'AlarmItem',

  components: {},

  props: {
    detail: {
      type: Object,
      default: () => ({})
    },
    hiddenResult: {
      type: Boolean,
      default: false
    }
  },

  data() {
    return {}
  },

  computed: {
    pushStaffNames() {
      const names = this.detail.pushStaffNames || []
      return names.join('，')
    },
    alarmSourceText() {
      return this.detail.alarmTypealarmType === 'over_speed_alarm' ? '触警车辆' : '触警人员'
    }
  },

  watch: {},

  created() {},

  mounted() {},

  destroyed() {},

  methods: {
    goDetail() {
      let menuName = '报警定位'
      let routerPath = `${staticUrl}/locate/alarm-event/positioning?code=${this.detail.id}&token=${getToken()}`
      let url = `/pages/work/report-form/query/view?title=${menuName}&url=${encodeURIComponent(routerPath)}`
      uni.navigateTo({
        url
      })
    }
  }
}
</script>

<style scoped lang="scss">
.background-white {
  background-color: #fff;
  padding: 0rpx 0rpx 0rpx 30rpx;
  view {
    padding: 14rpx 0;
    text {
      color: #333;
    }
  }

  .bor-btm {
    border-bottom: 1px solid #d5d7e3;
    padding: 24rpx 0;
    padding-right: 24rpx;
    color: #999;
  }
}
</style>
